home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / app / pattern_select_cmds.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-04  |  5.7 KB  |  260 lines

  1. /* The GIMP -- an image manipulation program
  2.  * Copyright (C) 1995-2000 Spencer Kimball and Peter Mattis
  3.  *
  4.  * This program is free software; you can redistribute it and/or modify
  5.  * it under the terms of the GNU General Public License as published by
  6.  * the Free Software Foundation; either version 2 of the License, or
  7.  * (at your option) any later version.
  8.  *
  9.  * This program is distributed in the hope that it will be useful,
  10.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  * GNU General Public License for more details.
  13.  *
  14.  * You should have received a copy of the GNU General Public License
  15.  * along with this program; if not, write to the Free Software
  16.  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17.  */
  18.  
  19. /* NOTE: This file is autogenerated by pdbgen.pl. */
  20.  
  21. #include "config.h"
  22.  
  23. #include "procedural_db.h"
  24.  
  25. #include <string.h>
  26.  
  27. #include "gimpcontext.h"
  28. #include "pattern_select.h"
  29.  
  30. static ProcRecord patterns_popup_proc;
  31. static ProcRecord patterns_close_popup_proc;
  32. static ProcRecord patterns_set_popup_proc;
  33.  
  34. void
  35. register_pattern_select_procs (void)
  36. {
  37.   procedural_db_register (&patterns_popup_proc);
  38.   procedural_db_register (&patterns_close_popup_proc);
  39.   procedural_db_register (&patterns_set_popup_proc);
  40. }
  41.  
  42. static PatternSelect *
  43. pattern_get_patternselect (gchar *name)
  44. {
  45.   GSList *list;
  46.   PatternSelect *psp;
  47.  
  48.   for (list = pattern_active_dialogs; list; list = g_slist_next (list))
  49.     {
  50.       psp = (PatternSelect *) list->data;
  51.       
  52.       if (psp->callback_name && !strcmp (name, psp->callback_name))
  53.     return psp;
  54.     }
  55.  
  56.   return NULL;
  57. }
  58.  
  59. static Argument *
  60. patterns_popup_invoker (Argument *args)
  61. {
  62.   gboolean success = TRUE;
  63.   gchar *name;
  64.   gchar *title;
  65.   gchar *pattern;
  66.   ProcRecord *prec;
  67.   PatternSelect *newdialog;
  68.  
  69.   name = (gchar *) args[0].value.pdb_pointer;
  70.   if (name == NULL)
  71.     success = FALSE;
  72.  
  73.   title = (gchar *) args[1].value.pdb_pointer;
  74.   if (title == NULL)
  75.     success = FALSE;
  76.  
  77.   pattern = (gchar *) args[2].value.pdb_pointer;
  78.  
  79.   if (success)
  80.     {
  81.       if ((prec = procedural_db_lookup (name)))
  82.     {
  83.       if (pattern && strlen (pattern))
  84.         newdialog = pattern_select_new (title, pattern);
  85.       else
  86.         newdialog = pattern_select_new (title, NULL);
  87.     
  88.       /* The callback procedure to run when pattern changes */
  89.       newdialog->callback_name = g_strdup (name);
  90.     }
  91.       else
  92.     success = FALSE;
  93.     }
  94.  
  95.   return procedural_db_return_args (&patterns_popup_proc, success);
  96. }
  97.  
  98. static ProcArg patterns_popup_inargs[] =
  99. {
  100.   {
  101.     PDB_STRING,
  102.     "pattern_callback",
  103.     "The callback PDB proc to call when pattern selection is made"
  104.   },
  105.   {
  106.     PDB_STRING,
  107.     "popup_title",
  108.     "Title to give the pattern popup window"
  109.   },
  110.   {
  111.     PDB_STRING,
  112.     "initial_pattern",
  113.     "The name of the pattern to set as the first selected"
  114.   }
  115. };
  116.  
  117. static ProcRecord patterns_popup_proc =
  118. {
  119.   "gimp_patterns_popup",
  120.   "Invokes the Gimp pattern selection.",
  121.   "This procedure popups the pattern selection dialog.",
  122.   "Andy Thomas",
  123.   "Andy Thomas",
  124.   "1998",
  125.   PDB_INTERNAL,
  126.   3,
  127.   patterns_popup_inargs,
  128.   0,
  129.   NULL,
  130.   { { patterns_popup_invoker } }
  131. };
  132.  
  133. static Argument *
  134. patterns_close_popup_invoker (Argument *args)
  135. {
  136.   gboolean success = TRUE;
  137.   gchar *name;
  138.   ProcRecord *prec;
  139.   PatternSelect *psp;
  140.  
  141.   name = (gchar *) args[0].value.pdb_pointer;
  142.   if (name == NULL)
  143.     success = FALSE;
  144.  
  145.   if (success)
  146.     {
  147.       if ((prec = procedural_db_lookup (name)) &&
  148.       (psp = pattern_get_patternselect (name)))
  149.     {
  150.       if (GTK_WIDGET_VISIBLE (psp->shell))
  151.         gtk_widget_hide (psp->shell);
  152.     
  153.       /* Free memory if poping down dialog which is not the main one */
  154.       if (psp != pattern_select_dialog)
  155.         {
  156.           gtk_widget_destroy (psp->shell);
  157.           pattern_select_free (psp);
  158.         }
  159.     }
  160.       else
  161.     success = FALSE;
  162.     }
  163.  
  164.   return procedural_db_return_args (&patterns_close_popup_proc, success);
  165. }
  166.  
  167. static ProcArg patterns_close_popup_inargs[] =
  168. {
  169.   {
  170.     PDB_STRING,
  171.     "pattern_callback",
  172.     "The name of the callback registered for this popup"
  173.   }
  174. };
  175.  
  176. static ProcRecord patterns_close_popup_proc =
  177. {
  178.   "gimp_patterns_close_popup",
  179.   "Popdown the Gimp pattern selection.",
  180.   "This procedure closes an opened pattern selection dialog.",
  181.   "Andy Thomas",
  182.   "Andy Thomas",
  183.   "1998",
  184.   PDB_INTERNAL,
  185.   1,
  186.   patterns_close_popup_inargs,
  187.   0,
  188.   NULL,
  189.   { { patterns_close_popup_invoker } }
  190. };
  191.  
  192. static Argument *
  193. patterns_set_popup_invoker (Argument *args)
  194. {
  195.   gboolean success = TRUE;
  196.   gchar *name;
  197.   gchar *pattern_name;
  198.   ProcRecord *prec;
  199.   PatternSelect *psp;
  200.  
  201.   name = (gchar *) args[0].value.pdb_pointer;
  202.   if (name == NULL)
  203.     success = FALSE;
  204.  
  205.   pattern_name = (gchar *) args[1].value.pdb_pointer;
  206.   if (pattern_name == NULL)
  207.     success = FALSE;
  208.  
  209.   if (success)
  210.     {
  211.       if ((prec = procedural_db_lookup (name)) &&
  212.       (psp = pattern_get_patternselect (name)))
  213.     {
  214.       GPattern *active = pattern_list_get_pattern (pattern_list, pattern_name);
  215.     
  216.       if (active)
  217.         {
  218.           /* Must alter the wigdets on screen as well */
  219.           gimp_context_set_pattern (psp->context, active);
  220.         }
  221.       else
  222.         success = FALSE;
  223.     }
  224.       else
  225.     success = FALSE;
  226.     }
  227.  
  228.   return procedural_db_return_args (&patterns_set_popup_proc, success);
  229. }
  230.  
  231. static ProcArg patterns_set_popup_inargs[] =
  232. {
  233.   {
  234.     PDB_STRING,
  235.     "pattern_callback",
  236.     "The name of the callback registered for this popup"
  237.   },
  238.   {
  239.     PDB_STRING,
  240.     "pattern_name",
  241.     "The name of the pattern to set as selected"
  242.   }
  243. };
  244.  
  245. static ProcRecord patterns_set_popup_proc =
  246. {
  247.   "gimp_patterns_set_popup",
  248.   "Sets the current pattern selection in a popup.",
  249.   "Sets the current pattern selection in a popup.",
  250.   "Andy Thomas",
  251.   "Andy Thomas",
  252.   "1998",
  253.   PDB_INTERNAL,
  254.   2,
  255.   patterns_set_popup_inargs,
  256.   0,
  257.   NULL,
  258.   { { patterns_set_popup_invoker } }
  259. };
  260.